DataGridViewSelectedRowCollection selectedRows = dgv_listStudent.Rows
    .OfType<DataGridViewRow>()  // 使用 OfType 替换 Cast 来获取 DataGridViewRow 类型的行
    .Where(row => row.Cells["checkBoxColumnIndex"].Value != null &&
                  (bool)row.Cells["checkBoxColumnIndex"].Value == true)
    .ToArray();